package com.ayx.springcloud.controller;

import com.ayx.springcloud.service.Paymentservice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class PaymentController {
    @Autowired
    private Paymentservice paymentservice;

    @GetMapping("/payment/ok/{id}")
    public String paymentOk(@PathVariable("id") Long id) {
        String result = paymentservice.paymentInfo_ok(id);
        return result;
    }

    @GetMapping("/payment/timeout/{id}")
    public String paymentTimeout(@PathVariable("id") Long id) {
        String result = paymentservice.paymentInfo_Timeout(id);
        return result;
    }

    //===服务熔断
    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id){
        String result = paymentservice.paymentCircuitBreaker(id);
        log.info("*******result:"+result);
        return result;
    }
}
